<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$Think.config.site.title} - 商户管理</title>
    <meta name="keywords" content="{$Think.config.site.keywords}">
    <meta name="description" content="{$Think.config.site.description}">
    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.min.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.min.css?v=4.0.0" rel="stylesheet">
</head>

<body class="">
    <div class="wrapper wrapper-content animated fadeInRight">
        <form method="post" class="form-horizontal" action="" id="myformdata" enctype="multipart/form-data">
            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-content">
                            <div class="form-group">
                                <input type="hidden" name="id" value="{$v.id}" />
                                <label class="col-sm-5 control-label">{:lang('地推姓名')}</label>
                                <div class="col-sm-7">
                                    <input type="text" class="form-control" name="agent_name" readonly value="{$v.agent_name}" id="agent_name" placeholder="{:lang('输入')}{:lang('姓名')}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-5 control-label">{:lang('电话号码')}</label>
                                <div class="col-sm-7">
                                    <input type="text" class="form-control" name="phone" value="{$v.phone}" readonly id="phone" placeholder="{:lang('输入')}{:lang('电话')}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-5 control-label">{:lang('所属代理商')}</label>
                                <div class="col-sm-7">
                                    <input type="text" class="form-control" name="belong_agent" readonly value="<?php echo $agent[$v['belong_agent']]['agent_name'];?>" id="real_name" placeholder="{:lang('输入')}{:lang('电话')}">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-5 control-label">{:lang('身份证号')}</label>
                                <div class="col-sm-7">
                                    <input type="text" class="form-control" id="card_sn" readonly value="{$v.phone}" name="card_sn" placeholder="{:lang('输入')}{:lang('身份证号')}">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-5 control-label">{:lang('身份证正面')}</label>
                                <div class="col-sm-7">
                                    <img src="{$v.card_pic_1}" class="img-responsive" alt="Cinque Terre" width="304" height="236">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-5 control-label">{:lang('身份证反面')}</label>
                                <div class="col-sm-7">
                                    <img src="{$v.card_pic_2}" class="img-responsive" alt="Cinque Terre" width="304" height="236">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-5 control-label">{:lang('手持身份证照片')}</label>
                                <div class="col-sm-7">
                                    <img src="{$v.card_pic_3}" class="img-responsive" alt="Cinque Terre" width="304" height="236">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-5 control-label">{:lang('用户状态')}</label>
                                <div class="col-sm-7">
                                    <input type="text" class="form-control" name="status" readonly value="<?php echo $status[$v['status']];?>" id="status" placeholder="{:lang('输入')}{:lang('状态')}">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </form>
    </div>

    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.5"></script>
    <script src="{$Think.config.site.resource_url}js/content.min.js?v=1.0.0"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/validate/jquery.validate.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/validate/messages_zh.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/chosen/chosen.jquery.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
</body>

</html>
<script>
$(document).ready(function(){
$('.chosen-select').chosen();
	$('#onbtn').click(function(){
        var agent_name = $('#agent_name').val();
        var phone = $('#phone').val();
        var area = $('#area').val();
        if(agent_name==''){
            $('#agent_name').focus();
            return false;
        }
        if(phone==''){
            $('#phone').focus();
            return false;
        }
        if(area==''){
            $('#area').focus();
            return false;
        }

		//var fomrData = $("#myformdata").serialize();
        var formData = new FormData($( "#myformdata" )[0]);
		var action = 'edit';
		$.ajax({
			type : 'POST',
			url : '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Agent/'+action,
			data: formData,
            async: false,
            cache: false,
            contentType: false,
            processData: false,
			success : function(result) {
                //layer.close(layer1);
                if(0 === result.code) {
                    layer.msg(result.msg, {icon: 1});
                    parent.location.reload();
                }  else  {
                    //删除失败
                    layer.msg(result.msg, {icon: 5});
                }
            },
            error : function(){
                res = false;
                layer.msg("{:lang('服务器错误！请稍后重试')}", {icon: 2});
            }
		})
	});
})
</script>

<script src="{$Think.config.site.resource_url}js/plugins/layer/laydate/laydate.js"></script>
<script>
    //外部js调用
    laydate({
        elem: '#hello', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
        event: 'focus' //响应事件。如果没有传入event，则按照默认的click
    });

    //日期范围限制
    var start = {
        elem: '#start',
        format: 'YYYY/MM/DD hh:mm:ss',
        min: laydate.now(), //设定最小日期为当前日期
        max: '2099-06-16 23:59:59', //最大日期
        istime: true,
        istoday: false,
        choose: function (datas) {
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日
        }
    };
    var end = {
        elem: '#end',
        format: 'YYYY/MM/DD hh:mm:ss',
        min: laydate.now(),
        max: '2099-06-16 23:59:59',
        istime: true,
        istoday: false,
        choose: function (datas) {
            start.max = datas; //结束日选好后，重置开始日的最大日期
        }
    };
    laydate(start);
    laydate(end);
</script>